package com.zhongge.servlet;

import com.zhongge.service.StudentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @ClassName DeleteStudentServlet
 * @Description TODO
 * @Author zhongge
 * @Version 1.0
 */
@WebServlet("/delete")
public class DeleteStudentServlet extends HttpServlet {
    StudentService studentService = new StudentService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取用户传出的id
        String id = req.getParameter("id");
        //进行删除(初步设计是包删除成功的)
        boolean re = studentService.deleteById(Integer.parseInt(id));
        //删除后只需要跳转到list servlet重新加载数据即可即可
        req.getRequestDispatcher("list").forward(req, resp);
    }
}
